home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
usenet
/
st80_pre4
/
cursor-from-text.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
2KB
|
59 lines
" NAME cursor-from-text
AUTHOR pieter@prls.UUCP (Pieter van der Meulen)
FUNCTION A routine to create a cursor from a string
ST-VERSIONS
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION 1.1
DATE 10 Mar 1989
SUMMARY
The following example allows you to create new Cursor
from a small String, e.g. 'S', 'III', or (5 printString).
A simple count down example is included in the comment
of the method below.
"
'
Newsgroups: comp.lang.smalltalk
Subject: A SMALLtalk-80 goodie
Keywords: example, source, smalltalk, cursor
Message-ID: <19836@prls.UUCP>
Organization: Philips Res. Labs, Sunnyvale, CA
Have fun, Pieter.
P.S. van der Meulen, MS 02 prls!!pieter
PRLS, Signetics div. of NAPC -----------
811 E.Arques Avenue, Sunnyvale, CA 94088-3409
'
!Cursor class methodsFor: 'instance creation'!
fromString: aString emphasis: anInteger
"Create a Cursor specified by aString.
Be sure to keep aString small, e.g. 'S' or '2'.
The emphasis is specified by anInteger and
could be 1 (normal), 2 (bold), 3 (italic), etc.
Written by Pieter S. van der Meulen."
"Cursor blank showWhile: [9 to: 0 by: -1 do: [:aNumber |
(Cursor fromString: aNumber printString emphasis: 2)
showWhile: [(Delay forMilliseconds: 500) wait]]]"
| aForm aCursor |
aForm _ (Text string: aString emphasis: anInteger) asDisplayText form.
aCursor _ Cursor
extent: 16 @ 16
fromArray: #(65535 32769 32769 32769 32769
32769 32769 32769 32769 32769 32769 32769 32769 32769 32769 65535)
offset: 0 @ 0.
aCursor
copyBits: aForm boundingBox
from: aForm
at: 8 @ 8 - aForm boundingBox center
clippingBox: (aCursor boundingBox insetBy: 1 @ 1)
rule: Form over
mask: Form black.
^aCursor! !